package com.ys.otms.controller;

import com.ys.otms.services.ICompanyServices;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/company")
public class CompanyController {

    private static Logger logger = LoggerFactory.getLogger(CompanyController.class);

    @Autowired
    private ICompanyServices iCompanyServices;

    @RequestMapping(value = "/queryCompany",method = RequestMethod.GET)
    @ResponseBody
    //公司信息-企业信息
    public JSONObject queryCompany(HttpServletRequest request) {
        logger.info("CompanyController queryCompany start ");
        JSONObject retObj = new JSONObject();
        try {
            retObj = iCompanyServices.queryCompany(request);
        } catch (Exception e) {
            logger.error("CompanyController queryCompany Exception", e);
            retObj.put("SUCCESS", false);
            retObj.put("MSG","查询失败，请联系管理员");
        }
        return retObj;
    }

    @RequestMapping(value = "/editCompany",method = RequestMethod.POST)
    @ResponseBody
    //修改公司
    public JSONObject editCompany(HttpServletRequest request) {
        logger.info("CompanyController editCompany start ");
        JSONObject retObj = new JSONObject();
        try {
            retObj = iCompanyServices.editCompany(request);
        } catch (Exception e) {
            logger.error("CompanyController editCompany Exception", e);
            retObj.put("SUCCESS", false);
            retObj.put("MSG","修改失败，请联系管理员");
        }
        return retObj;
    }
}
